package com.wooming.myserver.controller;

import com.wooming.myserver.dto.RankDTO;
import com.wooming.myserver.service.inter.RankService;
import com.wooming.myserver.util.PageResult;
import com.wooming.myserver.util.Result;
import com.wooming.myserver.vo.RankVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 排行榜控制器
 *
 * @author wooming 2025/05/27
 */
@RestController
public class RankController {

    private final RankService rankService;

    @Autowired
    public RankController(RankService rankService) {
        this.rankService = rankService;
    }

    @PostMapping("/api/public/rank")
    public Result<?> getRank(@RequestBody RankDTO rankDTO) {
        System.out.println("有人访问排行榜接口");   //监控后端API调用

        // 调用服务
        PageResult<RankVO> data = rankService.getRank(rankDTO);

        // 返回结果
        return Result.success(data);
    }
}
